< previous page page_375 next page >

Page 375
e10a6a0a59f035e870d90cca05b85fce.gif
    Shift As Integer, X As Single, Y As Single)
Dim wid As Single
Dim hgt As Single

    If Not SelectInProgress Then Exit Sub

    ' Erase the old box.
    Line (StartX, StartY)-(LastX, LastY), , B

    wid = X - StartX
    hgt = Y - StartY
    AdjustAspect ViewAspect, wid, hgt
    LastX = StartX + wid
    LastY = StartY + hgt

    ' Draw the new box.
    Line (StartX, StartY)-(LastX, LastY), , B
End Sub

' Finish selecting the region.
Private Sub Form_MouseUp(Button As Integer, _
    Shift As Integer, X As Single, Y As Single)
Dim wid As Single
Dim hgt As Single

    If Not SelectInProgress Then Exit Sub
    SelectInProgress = False

    ' Erase the old box.
    Line (StartX, StartY)-(LastX, LastY), , B

    ' Restore the original drawing mode.
    DrawMode = OldMode

    wid = X - StartX
    hgt = Y - StartY
    AdjustAspect ViewAspect, wid, hgt
    LastX = StartX + wid
    LastY = StartY + hgt

    ' Do something with the region
    ' (StartX, StartY) - (LastX, LastY).
    Line (StartX, StartY)-(LastX, LastY), vbRed, B
End Sub
Windows and Viewports in Visual Basic
World windows and viewports are interesting, but how do you use them in Visual Basic? The Visual Basic picture box control is ideal for use as a viewport.

 
< previous page page_375 next page >